package com.raimcomputing.pickforme.domain.dao;

import java.util.List;

public interface AbstractDao <DomainObject, KeyType> {

	/**
	 * Loads the object with the specified ID.
	 * 
	 * @param id The id of the object to load.
	 * @return The loaded object.
	 */
    DomainObject load(KeyType id);
    
    /**
     * Updates an existing object.
     * 
     * @param object The object to update.
     */
    void update(DomainObject object);

    /**
     * Saves a new object.
     * 
     * @param object The object to save.
     */
    void save(DomainObject object);

    /**
     * Delete the specified object.
     * 
     * @param object The object ot delete.
     */
    void delete(DomainObject object);
    
    /**
     * Delete the specified object.
     * 
     * @param id The id of the object to delete.
     */
    void deleteById(KeyType id);

    /**
     * Get's all instances of a specified class.
     * 
     * WARNING: This can be _very_ slow.
     * 
     * @return List of objects of the specified domain.
     */
    List<DomainObject> getAll();
    
    /**
     * Deletes all objects of the domain.
     * 
     * WARNING: Take care using this call.
     *
     */
    void deleteAll();
    
    /**
     * @return A count of all objects in the domain.
     */
    int count();
	
}
